{extend name='public/base' /}
{block name="css"}

{/block}
{block name="content"}
<div class="ibox xiaoshi">
    <div class="ibox-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="row">
                    <form class="form-inline" id="form">
                        <div class="col-sm-2">
                            <div class="input-group">
                                <div class="input-group-btn">
                                    <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">模型名称</button>
                                </div>
                                <input type="text" name="name" autocomplete="off" class="form-control"  placeholder="请输入名称">
                            </div>
                        </div>

                        <div class="col-sm-2">
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</button>
                        </div>

                    </form>
                </div>

            </div>

        </div>

    </div>
</div>


<div class="row">
    <div class="col-sm-12">
        <div class="ibox">
            <div class="ibox-content">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-primary btn-rounded single {:node('article.ArticleModel/edit')}" onclick="$.form.edit()">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                </div>
                <div class="table-striped">
                    <table id="bootstrap-table" ></table>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"} <!--js处理区-->

<script>
    $(function() {
        var options = {
            url: "{:url('index')}",
            deleteUrl:  "{:url('del')}?id={id}", //删除链接
            exportUrl:  "{:url('export')}",  //导出
            updateUrl: "{:url('edit')}?id={id}", //编辑
            addUrl:    "{:url('add')}", //添加
            detailUrl:  "/detailUrl",    //详细
            sortName: "id",
            sortOrder: "desc",
            modalName: "模型",
            onDblClickRow:onDblClickRow, //双击行编辑
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID'
                },
                {
                    field: 'name',
                    title: '模型名'
                },
                {
                    field: 'tablename',
                    title: '表名'
                },
                {
                    field: 'index_template',
                    title: '首页模板'
                },
                {
                    field: 'list_template',
                    title: '列表页模板'
                },
                {
                    field: 'show_template',
                    title: '详情页模板'
                },
                {
                    field: 'sort',
                    title: '排序'
                },
                {
                    field: 'create_time',
                    title: '添加时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return edit_del(row);
                    }

                }]
        };
        $.table.init(options);
    });

    function edit_del(row) {
        var actions = [];
        actions.push('<a class="btn btn-xs btn-success  {:node(\'article.ArticleModel/edit\')}" data-original-title="编辑" data-toggle="tooltip" onclick="$.form.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i></a>');
        return actions;
    }

    //双击行编辑
    function onDblClickRow(row) {
        $.form.edit(row.id);
    }


</script>

{/block}
